﻿using System;
using System.Data;

namespace UDS.Entity
{
    /// <summary>
    /// Describes a record in UDS_Class table.
    /// </summary>
    public class ClassInfo
    {
        #region properties
        public int ID
        {
            get;
            set;
        }

        public int ParentID
        {
            get;
            set;
        }

        public string Name
        {
            get;
            set;
        }

        public string Description
        {
            get;
            set;
        }

        public ClassType Type
        {
            get;
            set;
        }

        public string Creator
        {
            get;
            set;
        }

        public DateTime TimeCreated
        {
            get;
            set;
        }

        public int Status
        {
            get;
            set;
        }
        #endregion

        internal static ClassInfo ReadClassInfo(IDataReader dr)
        {
            ClassInfo c = new ClassInfo();
            c.ID = (int)dr["ClassID"];
            c.ParentID = SQLUtil.ReadInt32(dr["ClassParentID"], c.ID);
            c.Name = Convert.ToString(dr["ClassName"]);
            c.Description = Convert.ToString(dr["ClassRemark"]);
            c.Type = (ClassType)((int)dr["ClassType"]);
            c.Creator = Convert.ToString(dr["ClassAddedBy"]);
            c.TimeCreated = SQLUtil.ReadDataTime(dr["ClassAddedDate"], DateTime.MinValue);
            c.Status = SQLUtil.ReadInt32(dr["Status"], 0);

            return c;
        }
    }
}
